<template>
  <div class="heard">
    <div class="heard_up">
      <div class="heard_up1">
        <div class="heard_up_left">
          <h6>欢迎使用吾顺二手书交易网站</h6>
        </div>
        <div class="heard_up_right">
          <router-link :to="{ name: 'login' }" v-if="islogin">登录</router-link>
          <router-link :to="{ name: 'register' }" v-if="islogin"
            >注册</router-link
          >
          <router-link :to="{ name: 'managedmybook' }">我要出售</router-link>
          <router-link :to="{ name: 'customer' }">联系客服</router-link>
          <router-link :to="{ name: 'personal' }">个人中心</router-link>
          <router-link :to="{ name: 'cart' }"
            >购物车
          </router-link>
          <router-link :to="{ name: 'personal' }" v-if="!islogin">
            <el-avatar
              icon="el-icon-user-solid"
              :src="api + useriocn"
            ></el-avatar>
          </router-link>
          <router-link :to="{ name: 'personal' }" v-if="!islogin">
            <el-dropdown>
              <span class="el-dropdown-link">
                {{ user }}<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item class="clearfix">
                  <span @click="personal()">个人资料</span>
                  <el-badge class="mark" />
                </el-dropdown-item>
                <el-dropdown-item class="clearfix" index="/my">
                  <span @click="exit()">安全退出</span>
                  <el-badge class="mark" />
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </router-link>
        </div>
      </div>
    </div>
    <div class="heard_down">
      <div class="heard_down_left">
        <a href=""><img src="@/assets/images/logo.png" alt=""/></a>
      </div>
      <div class="heard_down_center">
        <router-link :to="{ name: 'index' }" exact
          ><span>首页</span></router-link
        >
        <router-link :to="{ name: 'category' }" exact
          ><span>分类</span></router-link
        >
        <router-link :to="{ name: 'about' }" exact
          ><span>关于</span></router-link
        >
        <router-link :to="{ name: 'contact' }" exact
          ><span>联系</span></router-link
        >
      </div>
    </div>
  </div>
</template>

<script>
export default {
  inject: ["reload"],
  data() {
    return {
      search: "",
      islogin: true,
      user: sessionStorage.getItem("nickname"),
      useriocn: sessionStorage.getItem("usericon"),
      api: this.imageapi
    };
  },
  computed: {
    // count(){
    //   let count = 0;
    //   for (let i = 0; i < this.itemlis.length; i++) {
    //     let item = this.itemlis[i];
    //     count += item.number;
    //   }
    //   return count.toString().replace(/\B(?=(\d{3})+$)/g, ",");
    // }
  },
  created() {
    if (sessionStorage.getItem("loginname")) {
      this.islogin = false;
    }
  },
  mounted() {},
  methods: {
    exit() {
      this.$router.push({path: "/"})
      window.sessionStorage.clear();
      location.reload();
    },
    personal() {
      this.$router.push({ name: "myinfo" });
    }
  }
};
</script>

<style scoped>
.heard {
  width: 100%;
}
.heard .heard_up {
  /* position: fixed;
  top: 0;
  z-index: 9999; */
  width: 100%;
  background: #f7f7f7;
  /* opacity: 0.9; */
}
.heard .heard_up1 {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 1200px;
  height: 50px;
  background: #f7f7f7;
  margin: 0 auto;
}
.heard .heard_up .heard_up_left h6 {
  color: rgb(43, 87, 162);
}
.heard .heard_up .heard_up_right {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
}
.heard .heard_up .heard_up_right a {
  padding-right: 10px;
  color: #2b57a2;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
}
.heard .heard_down {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 1200px;
  height: 80px;
  line-height: 80px;
  margin: 0 auto;
  border-bottom: 2px solid #dfe2e9;
  /* margin-top: 50px; */
}
.heard .heard_down .heard_down_left {
  width: 180px;
  height: 50px;
  line-height: 50px;
}
.heard .heard_down .heard_down_left img {
  width: 100%;
  height: 100%;
}
.heard .heard_down .heard_down_center a {
  padding-right: 40px;
  font-weight: 600;
  font-size: 18px;
}
.heard .heard_down .heard_down_center a span:hover,
.heard .heard_down .heard_down_center a span:active {
  color: #333;
  border-bottom: 2px solid #333;
  padding-bottom: 5px;
}
.router-link-active span {
  color: #333;
  border-bottom: 2px solid #333;
  padding-bottom: 5px;
}
</style>
